﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using RuleCode.Table;

namespace map.member.lvyou
{
    public partial class newviewpointplace : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            GridViewBind();
        }
        protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            //string id = GridView1.DataKeys[e.RowIndex].Value.ToString();
            //BizArea uc = BizArea.Find(" recid = '" + id + "'", "RECID");
            //uc.Delete();
            //GridViewBind();
        }

        protected void GridView1_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
        {
            string id = GridView1.DataKeys[e.NewSelectedIndex].Value.ToString();
            lyviewpointplace uc = lyviewpointplace.Find(" recid = '" + id + "'", "RECID");

            TextBox1.Text = uc.lyviewpointplacename.ToString();
            TextBox4.Text = uc.lyplacekeword.ToString();
            //TextBox_lat.Text = uc.taobaolat.ToString();
            Fck_Content.Value =Server.HtmlDecode( uc.jcdesc1.ToString());
            Label_recid.Text = uc.RECID.ToString();
           
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
           // if (DropDownList1.Text != "" && DropDownList2.Text != "")
            {
                lyviewpointplace uc = lyviewpointplace.Find(" 1=2 ");
                uc.New();
                uc.lyviewpointplacename.Value = TextBox1.Text;
                uc.lyplacekeword.Value = TextBox4.Text;
                uc.jcdesc1.Value = Fck_Content.Value;
                //uc.lyviewpointid.Value = TextBox1.Text;
                //uc.valid.Value = RuleCode.Enum.NoYes.No;
                //todo:change after finished login function
                //finished
                uc.cbuserid = AliApi.appUserId;

               
                uc.Insert();
                GridViewBind();
            }
            //else
            {
               // MessageBox.Show(this.UpdatePanel1, "操作不成功.");
            }
        }
        private void GridViewBind()
        {
            RuleCode.Table.lyviewpointplace x = RuleCode.Table.lyviewpointplace.Find("cbuserid = '" + AliApi.appUserId + " '");
            this.GridView1.DataSource = x.MyTable;
            this.GridView1.DataBind();

        }

        protected void Button2_Click(object sender, EventArgs e)
        {
            lyviewpointplace x = lyviewpointplace.Find(" recid = '" + Label_recid.Text + "'", "RECID");
            x.lyviewpointplacename.Value = TextBox1.Text;
            x.lyplacekeword.Value =TextBox4.Text;
            x.jcdesc1.Value = Fck_Content.Value;
            x.Modify();
            GridViewBind();
        }
    }
}
